<template>
	<view class="">
		<view :class="shadow?'shadow':''">
			<view class="dinwei2">
				<view class="position-fixed" style="top: 0;left: 0;width: 100%;z-index: 100;">
					<view :class="bg_color" style="width: 100%;" :style="{'height':$common.headHeight() + 'px'}"></view>
					<view :class="bg_color" class=" position-relative " style="height: 44px;width: 100%;">
						<!-- #ifndef MP-WEIXIN -->
						<view class="zuofu">
							<text :class="['iconfont icon-homeiconfanhui p-l15 p-r5 f-s18 f-w800',color]" v-if="fanStatus" @click="fanhui"></text>
							<!-- <text :class="['iconfont icon-chahao p-l15 f-s18 f-w800',color]" v-if="cross" @click="putNo"></text> -->
						</view>
						<view :class="['f-w800 f-s16 text-center',color]" style="line-height: 44px;">{{title}}</view>
						<view class="youfu d-flex align-center">
							<slot></slot>
						</view>
						<!-- #endif -->
						<!-- #ifdef MP-WEIXIN -->
						<view class="zuofu d-flex align-center">
							<text :class="['iconfont icon-homeiconfanhui m-r10 p-l15 p-r5 f-w800',color]" v-if="fanStatus" @click="fanhui"></text>
							<view class="d-flex align-center">
								<slot></slot>
							</view>
						</view>
						<view :class="['f-w800 text-center',color]" style="line-height: 44px;">{{title}}</view>
						<!-- #endif -->
					</view>
				</view>
			</view>
			<view v-if="isHeight" :style="{'height': ($common.headHeight() + 44) + 'px'}"></view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
			}
		},
		props:{
			title:{
				type: String,
				default: ' '
			},
			fanStatus:{
				type:Boolean,
				default:true
			},
			shadow:{
				type:Boolean,
				default:false
			},
			color:{
				type: String,
				default: 'co_000'
			},
			urlLink: {
				type: String,
				default: ''
			},
			bg_color: {
				type: String,
				default: 'bg_43A7F2'
			},
			isHeight:{
				type:Boolean,
				default:true
			},
			cross:{
				type:Boolean,
				default:false
			}
		},
		created() {
		},
		methods:{
			fanhui() {
				let pages = getCurrentPages();  //获取所有页面栈实例列表
				if(pages.length < 2){
					this.$common.redirectTo('/pages/login/login',true)
				}else{
					if(pages[pages.length -1].route == 'pages/aDraftList/aDraftList') {
						this.$common.redirectTo('/pages/home/home',true)
					}else {
						uni.navigateBack()
					}
				}
			},
			confirm() {
				uni.navigateBack()
			},
			// 分享小程序
			share1(){
				let v = '?'
				if(this.urlLink.indexOf("?") != -1) {
					v = '&'
				}else {
					v = '?'
				}
				// #ifdef APP-PLUS || APP-PLUS-NVUE
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 5,
					title: '宁夏惠龙易盛',
					miniProgram: {
						id: 'gh_79d0d700373c',
						path: this.urlLink + v +'invite='+ this.$db.get('myShareCode') ,
						type: 0,
						webUrl: '' //this.$store.state.baseUrl
					},
					imageUrl: '', //uni.fenxiang,
					success: function (res) {}
				});
				// #endif
			},
			putNo() {
				let _this = this
				uni.showModal({
					title: '温馨提示',
					content: '您确定要退出登录',
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
							_this.$common.show('退出登录成功')
							setTimeout(() => {
								_this.$db.del('userInfo')
								_this.$db.del('token')
								_this.$common.guanbi('/pages/login/login')
							},1000)
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zuojiantou{
		width: 50rpx;
		height: 50rpx;
		background-color: rgba(255,255,255,.8);
		border-radius: 50%;
	}
	.dinwei2{
		// position: fixed;
		// top: 0;
		// left: 0;
		// width: 100%;
		// z-index: 100;
	}
	.zuofu{
		position: absolute;
		left: 0;
		top: 50%;
		transform: translate(0,-50%);
	}
	.youfu{
		position: absolute;
		right: 30rpx;
		top: 50%;
		transform: translate(0,-50%);
	}
	.shadow{
		box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.1);
	}
	.henxing{
		width: 220rpx;
		height: 68rpx;
		background: #FF4F43;
		border-radius: 42rpx;
		line-height: 68rpx;
	}
</style>
